package com.cx.util.device;

import android.content.Context;
import android.net.Uri;
import android.os.Build;

import androidx.core.content.FileProvider;


import com.cx.util.AppUtils;

import java.io.File;

public class UriHelper {


    public static Uri getFileUri(File file) {
        Context context = AppUtils.getApp();
        String authority = context.getPackageName() + AppUtils.FILE_PROVIDER;
        return getFileUri(file, authority);
    }


    public static Uri getFileUri(File file, String authority) {
        Context context = AppUtils.getApp();
        Uri uri;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            uri = FileProvider.getUriForFile(context, authority, file);
        } else {
            uri = Uri.fromFile(file);
        }
        return uri;
    }
}
